Use case: SYSTICK configuration

These sequences demonstrate the change in the SYSTICK configuration.

Sequence diagram

SYSTICK configuration

  @startuml

  group Configure the SYSTICK
  "User Application"->"Driver Cortex" : HAL_SYSTICK_CLKSourceConfig()
  "User Application"->"Driver Cortex" : HAL_SYSTICK_Config()
  end

  @enduml

Code snippet

This use case demonstrates how to configure the SYSTICK timer using HAL1 compared to HAL2.

HAL1

HAL2

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* Fix the number of ticks between two interrupts */
TicksNumb = 1000;
uint32_t state = HAL_SYSTICK_Config(TicksNumb);
HAL_CORTEX_SYSTICK_SetClkSource(HAL_CORTEX_SYSTICK_CLKSOURCE_INTERNAL);

/* SysTick clock frequency is 1 MHz */
uint32_t SysTick_CLK = 1000000;
HAL_CORTEX_SYSTICK_SetFreq(SysTick_CLK);

Key changes

  1. In HAL2, HAL_CORTEX_SYSTICK_Config() is replaced with HAL_CORTEX_SYSTICK_SetFreq(), which uses a frequency parameter instead of a tick count.

  2. In HAL2, the clock source is configured using HAL_CORTEX_SYSTICK_SetClkSource().